<template>
  <el-dialog
    title="修改"
    :close-on-click-modal="false"
    class="full_screen_dialog "
    width="95%"
    :visible.sync="visible"
  >
    <el-tabs v-model="activeName">
      <el-tab-pane label="商品信息" name="first">
        <goods ref="goods" />
      </el-tab-pane>
      <el-tab-pane label="规格属性" name="third" />
      <el-tab-pane label="商品相册" name="fourth">
        <gallery ref="gallery" />
      </el-tab-pane>
    </el-tabs>
  </el-dialog>
</template>
<script>
import goods from './components/goods'
import gallery from './components/gallery'
export default {
  components: {
    goods,
    gallery
  },
  data() {
    return {
      visible: false,
      activeName: 'first'
    }
  },
  methods: {
    init(id) {
      this.visible = true
      this.$nextTick(() => {
        const goods = this.$refs['goods']
        if (goods != null) {
          this.$http({
            url: this.$http.adornUrl(`/goods/wares/info/${id}`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({ data }) => {
            if (data && data.code === 0) {
              goods.init(data.goods)
            }
          })
        }
      })
    }
  }
}
</script>
